import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Index from "../views/Index.vue";
import Vues from "../views/404.vue";
import redirect from "../views/redirect/index.vue"
import UserInfo from "../views/admin/UserInfo.vue"
import Passwords from "../views/admin/ChangePasswords.vue"
// import pages from "@/router/page"
Vue.use(VueRouter);

const routes = [
  // 默认显示首页
  {
    path: "/index",
    redirect:"/index/home"
  },
  // 登录页面
  {
    path: "/login",
    name: "login",
    component: Login,
  },
  {
  // 404页面
    path: "*",
    name: "vues",
    component: Vues,
  },
  // 主页面
  {
    path: "/index",
    name: "index",
    component: Index,
    // redirect:'/index/home' //重定向路由，进去以后显示首页
    children:[
      {
        path:"redirect/:path(.*)",
        name:"redirect",
        component:redirect,  //空白页中转，用于页面刷新
      },
      {
            path: "userinfo",
            name: "userinfo",
            component: UserInfo,
            meta: {
              title: "用户信息",
          }
      },
      {
        path: "passwords",
        name: "passwords",
        component: Passwords,
        meta: {
          title: "修改密码",
      }
  }
    ]

  },

];
const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
